Return type | Name and parameters |
---|---|
float[]
|
column(int col)
Select a column from a 2D array. |
float[][]
|
eachColumn(Closure closure)
Process the columns of the array. |
List
|
flatten()
Flattens a 2D array into a new collection. |
float[][]
|
transpose()
A transpose method for 2D float arrays. |
Iterator
|
transposing()
An iterator of the columns of the array. |
Select a column from a 2D array.
float[][] nums = [[1.0f, 2.0f], [10.0f, 20.0f]] assert nums.column(0) == [1.0f, 10.0f] as float[] assert nums.column(1) == [2.0f, 20.0f] as float[]
Process the columns of the array.
double[][] nums = [[1.0f, 2.0f], [10.0f, 20.0f]] nums.eachColumn { assert it[0] * 10.0f == it[1] }
closure
- the closure applied on each array columnFlattens a 2D array into a new collection. The items are copied row by row.
Example usage:
float[][] array = [[0.0f, 1.0f], [2.0f, 3.0f]] assert array.flatten() == [0.0f, 1.0f, 2.0f, 3.0f]
A transpose method for 2D float arrays.
Example usage:
float[][] floats = [[1.0f, 10.0f], [2.0f, 20.0f]] float[][] expected = [[1.0f, 2.0f], [10.0f, 20.0f]] def result = floats.transpose() assert result == expected assert floats.class.componentType == result.class.componentType
An iterator of the columns of the array.
float[][] nums = [[1.0f, 2.0f], [10.0f, 20.0f]] assert nums.transpose() == nums.transposing().toList()